#pragma once
#include<algorithm>
template<class T=int,int size=50>
class myHeap_static {
	T m_nums[size];
	int m_cnt=0;
	void down() {
		for (int i=0;i<m_cnt;) {
			int next = 2 * (i + 1) < m_cnt && m_nums[2 * (i + 1)] > m_nums[2 * i + 1] ? 2 * (i + 1) : 2 * i + 1;
			if (m_nums[i] > m_nums[next]) break;
			swap(m_nums[i], m_nums[next]);
			i = next;
		}
	}
	void up(int index) {
		for (int i = index; i > 0;) {
			if ((i-1)/2>=0 && m_nums[(i - 1) / 2] < m_nums[i])
			{
				swap(m_nums[(i - 1) / 2], m_nums[i]);
				i = (i - 1)/2;
			}
			else
			{
				break;
			}
		}
	}
public:
	myHeap_static() = default;
	~myHeap_static() = default;
	bool insert(T val) {
		if (m_cnt == size) return false;
		m_nums[m_cnt] = val;
		up(m_cnt++);
	}
	T getTop() {
		return m_nums[0];
	}
	bool pop() {
		if (m_cnt == 0) return false;
		swap(m_nums[0], m_nums[--m_cnt]);
		down();
	}
};